# -*- coding: utf-8 -*-
from datetime import timedelta

from utils.operators.cluster_for_spark_sql_operator import SparkSqlOperator

from jms.dm.dm_cn_breakoff_detail_reading_dt import jms_dm__dm_cn_breakoff_detail_reading_dt

jms_dm__dm_cn_breakoff_agg_reading_dt = SparkSqlOperator(
    task_id='jms_dm__dm_cn_breakoff_agg_reading_dt',
    email=['jarl.huang@jtexpress.com','yl_bigdata@yl-scm.com'],
    name='jms_dm__dm_cn_breakoff_agg_reading_dt_{{ execution_date | date_add(1) | cst_ds }}',
    sql='jms/dm/dm_cn_breakoff_agg_reading_dt/execute.hql',
    pool_slots=5,
    executor_cores=2 , 
    executor_memory='2G' , 
    driver_memory='3G' , 
    num_executors=2 , 
    conf={
        'spark.dynamicAllocation.maxExecutors'             : 2 , 
          'spark.sql.sources.partitionOverwriteMode': 'dynamic',
          'spark.dynamicallocation.enabled': 'true',
          'spark.dynamicAllocation.cachedExecutorIdleTimeout': 120,
          'spark.shuffle.service.enabled': 'true',
          'spark.sql.shuffle.partitions': 600
          },
    hiveconf={'hive.exec.dynamic.partition': 'true',
              'hive.exec.dynamic.partition.mode': 'nonstrict',
              'hive.exec.max.dynamic.partitions.pernode': 5000,
              'hive.exec.max.dynamic.partitions': 30000
              },
    yarn_queue='pro',
    execution_timeout=timedelta(minutes=60),
)

jms_dm__dm_cn_breakoff_agg_reading_dt << jms_dm__dm_cn_breakoff_detail_reading_dt
